﻿using System;
using System.Linq.Expressions;

namespace CompactMapper.Orm.Queries
{
    internal sealed class LongEqualsCriterion<T> : Criterion<T, long>
    {
        private readonly Expression<Func<T, long>> _columnExpression;

        public LongEqualsCriterion(Expression<Func<T, long>> columnExpression, long targetValue)
            : base(columnExpression, targetValue)
        {
            _columnExpression = columnExpression;
        }

        public override CriterionType Type
        {
            get { return CriterionType.LongEquals; }
        }


        public override bool Validate(T entity)
        {
            return _columnExpression.Compile().Invoke(entity).Equals(TargetValue);
        }
    }
}